<? 
session_start();
if(!session_is_registered(uid)){
    echo "You have to login to view this page!</br></br>";
    echo "Click here to return to the "; 
    echo '<a href="./../index.php" title="Login">Login Page</a></br></br>';
    echo "Or sign up using this link ";
    echo '<a href="./../Registration/registration.html" title="Registration">Registration Page</a>';
exit();
}
else  
    
    //Add tank form option
    include 'Lighting.html';
    
    //Manual SQL Connection
    $con = mysql_connect("localhost", "root", "root") or die ( "Error connectiong to DB: ".mysql_error());
       
    mysql_select_db("reeferslog", $con) or die ( "Error selecting specific DB, reefeerslog: ".mysql_error());
    
    //Variables
    $bulb = $_POST['bulb'];
    $watt = $_POST['wattage'];
    $kel = $_POST['kelvin'];
    $qty = $_POST['qty'];
    $manufacturer = $_POST['manufacturer'];
    $cost = $_POST['cost'];
    
    //Date variables
    $day = $_POST['day'];
    $month = $_POST['month'];
    $year = $_POST['year'];
    
    //Function to make a valid date input
    $date = $year."-".$month."-".$day;
    
    //Function to make a valid date input
    $datechange = $year."-".$month."-".$day;
      
    //SQL Query to add tank info
    $addbulb = "insert into l_bulbs (user_id,watt,manufacturer,k_rating,dateinstalled,bulb_type,replacementdate,qty,cost) values ('". $_SESSION['uid'] ."','$watt','$manufacturer','$kel','$date','$bulb','$datechange','$qty','$cost')";

        //Execute Insert command
        if (!mysql_query($addbulb,$con))
            {
              die('Error: ' . mysql_error());
            }
            echo "Bulbs added successfully!"; 
               
    //Close SQL input
    mysql_close($con);
?>
